package fina2.dcs.fis;

import java.io.Serializable;
import java.util.List;

import javax.ejb.Remove;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.jboss.annotation.ejb.LocalBinding;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Destroy;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.log.Log;
import org.jboss.seam.log.Logging;

@Stateful
@LocalBinding(jndiBinding = "MMBankGroupSession/local")
@Scope(ScopeType.SESSION)
@SuppressWarnings("unchecked")
@AutoCreate
public class MMBankGroupSession implements MMBankGroupLocal,Serializable {
	
	@Logger
	private Log log;

	@PersistenceContext
	private EntityManager em;

	public List<MMBankGroup> findByBankId(float bankId) {
		List<MMBankGroup> mm = null;
		try {
			mm = em.createQuery("FROM " + MMBankGroup.class.getName() + " mm WHERE mm.bankGroupPk.bankId IN(" + bankId + ")").getResultList();
		} catch (Exception ex) {
			log.error(ex.getMessage(), ex);
		}
		return mm;
	}

	@Remove
	@Destroy
	public void remove() {

	}

	public void addMMBankGroup(MMBankGroup mmGroup) {
		try {
			em.persist(mmGroup);
		} catch (Exception ex) {
			log.error(ex.getMessage(), ex);
		}
	}

}
